//
//  SignInInfoTableViewCell.m
//  OAProject
//
//  Created by yhj on 2017/2/24.
//  Copyright © 2017年 cdnunion. All rights reserved.
//

#import "SignInInfoTableViewCell.h"

@interface SignInInfoTableViewCell ()

// 头像
@property(nonatomic,strong)UIImageView *headURL;

// 名字
@property(nonatomic,strong)UILabel *nameLabel;

// 任务数量
@property(nonatomic,strong)UILabel *countLabel;

@end

@implementation SignInInfoTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        // ➡️Cell类型
        self.accessoryType=UITableViewCellAccessoryNone;

        self.headURL.hidden=NO;

        _headURL.image=[UIImage imageNamed:@"head"];

        self.nameLabel.font=Font_Number(18);

        self.countLabel.font=Font_Number(14);

        self.backgroundColor=WhiteColor;

    }
    return self;
}

// headURL
-(UIImageView *)headURL
{
    if (!_headURL) {
        _headURL=[[UIImageView alloc]init];
        [self.contentView addSubview:_headURL];
        // 圆角和边框
        ViewBorderRadius(_headURL,kmargin*5/2,kmargin/kmargin,ClearColor);

        [_headURL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.mas_equalTo(kmargin);
            make.size.mas_equalTo(CGSizeMake(kmargin*5,kmargin*5));
        }];
    }
    return _headURL;
}

// nameLabel
- (UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel=[self getLabelWithText:[Util getUserDefaultObjectForKey:@"admin_name"] font:Font_Number(16) textColor:BlackColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_nameLabel];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.headURL.mas_right).offset(kmargin);
            make.centerY.mas_equalTo(self.headURL.mas_centerY);
        }];
    }
    return _nameLabel;
}

// countLabel
- (UILabel *)countLabel
{
    if (!_countLabel) {

        _countLabel=[self getLabelWithText:@"今日任务2个" font:Font_Number(14) textColor:WhiteColor textAlignment:NSTextAlignmentCenter lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        _countLabel.backgroundColor=Main_Color;
        ViewBorderRadius(_countLabel,kmargin/2,1,ClearColor);
        [self.contentView addSubview:_countLabel];
        [_countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-kmargin*2);
            make.centerY.mas_equalTo(self.headURL.mas_centerY);
        }];
    }
    return _countLabel;
}

-(void)setTaskModel:(TaskModel *)taskModel
{
    _countLabel.text=[NSString stringWithFormat:@"今日任务%ld个",(long)taskModel.today_task_num];
}

@end
